﻿namespace TestApp.DataService
{
    using System;
    using System.Diagnostics.Contracts;
    using Contracts;

    public sealed class DataRandomizer : IDataRandomizer
    {
        private readonly Random _rnd = new Random();

        public int GenerateIndex()
        {
            Contract.Ensures(Contract.Result<int>() >= 0 && Contract.Result<int>() < EntityDto.ParameterCount);
            return _rnd.Next(DataEntityDto.EntityCount);
        }

        public double GenerateParameterValue()
        {
            Contract.Ensures(Contract.Result<double>() >= -1d && Contract.Result<double>() <= 1d);
            return _rnd.NextDouble() * 2d - 1d;
        }
    }
}
